package ch14;
import java.io.*;

class _11_DataInputStreamEx2 {
	public static void main(String args[]) {
		int sum = 0;
		int score = 0;

		FileInputStream fis = null;
		DataInputStream dis = null;

		try {
			fis = new FileInputStream("c:/score.dat");
			dis = new DataInputStream(fis);

			while(true) {
				score = dis.readInt();
				System.out.println(score);	
				sum += score;
			}
		} catch (EOFException e) {
			System.out.println("total score: " + sum);
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if(dis!=null) dis.close();			
			} catch(IOException e){
				e.printStackTrace();			
			}
		}
	}
}
/*
100
90
95
85
50
total score: 420
*/
